//
// Created by xili on 2024/9/2 18:07.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int minOperations(vector<int> &nums) {
        unordered_map<int, int> ump;
        for (auto &v: nums) {
            ump[v]++;
        }
        int ans = 0;
        for (auto &[v, c]: ump) {
            if (c == 1) {
                return -1;
            }
            ans += (c + 2) / 3;
        }
        return ans;
    }
};